package com.wen.springboot_db_20210510.dao;

import com.wen.springboot_db_20210510.beans.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao {

    //通过id查询
    @Select("select * from person where id=#{id}")
    UserInfo getUserById(@Param("id") int id);

    //根据卡号查询
    @Select("select * from person where cardno=#{cardno}")
    UserInfo getUserByCardno(@Param("cardno") String cardno);

    //新增人员
    @Insert("insert into person(cardno,psname) values(#{cardno},#{psname})")
    int insertUser(@Param("cardno") String cardno, @Param("psname") String psname);

    //查询全部
    @Select("select * from person")
    List<UserInfo> getAllUser();

    //删除人员信息
    @Delete("delete from person where id = #{id}")
    int deleteById(@Param("id") int id);

    //更新信息
    @Update("update person set cardno=#{cardno},psname=#{psname} where id = #{id}")
    int updateUser(@Param("id") int id, @Param("cardno") String cardno, @Param("psname") String psname);

}
